<?php

namespace App\Http\Controllers\Admin;


use App\Http\Controllers\AdminController;
use App\Models\System\Menus;
use App\Models\System\Sites;

class IndexController extends AdminController
{

    public function systemMenus()
    {
        $userAllPermissions = $this->userAllPermissions();
        $arr = [];
        if ($list = Menus::getAllMenus()) {
            foreach ($list as $value) {
                if ($value["genre"] !== 2 && ($userAllPermissions && isset(array_flip($userAllPermissions)[$value["name"]]))) {
                    $arr[] = $this->sysPerData($value);
                }
            }
            $arr = listToTree($arr, 'id', 'parent_id', 'list');
            array_unshift($arr, $this->homeMenus());
        }
        return $this->succeed([
            'menus' => $arr,
            'permissions' => $userAllPermissions,
        ]);
    }

    public function webSite()
    {
        $config = Sites::GetPluginSet('website');
        $config['upload'] = config("custom.upload");
        return $this->succeed($config);
    }

}
